<#include "dictionary.html"/>
<#macro input name extend index value='' type='form' safe=true>
    <#local inputName=name+'['+index+'].value'/>
    <#local inputValuesName=name+'['+index+'].values'/>
    <input name="${name}[${index}].name" type="hidden" value="${extend.id.code}"/>
    <#switch extend.inputType>
        <#case 'number'>
            <#if 'view'=type>
                ${(value)!}
            <#else>
            <input name="${inputName}" <#if 'customform'!=type>class="number<#if extend.required> required</#if>" </#if>type="number"<#if extend.maxlength?has_content> maxlength="${extend.maxlength}"</#if> value="${(value)!}"/>
            </#if>
            <#break>
        <#case 'file'>
            <#if 'view'=type>
                <a href="${getAbsoluteUrl(site.sitePath,value)!}" target="_blank">${(value)!}</a>
            <#else>
                <input name="${inputName}" <#if 'customform'!=type>class="<#if extend.required>required</#if>" type="text" maxlength="300" size="50" <#else>type="file" </#if>value="${(value)!}"/>
                <#if 'customform'!=type>
                    <a class="btnAttach" href="common/upload.html?field=${inputName?url}" lookupGroup="" width="1000" height="600"><@t.page 'attach'/></a>
                    <a class="view icon-eye-open" ref="${inputName}" data-prefix="${site.sitePath}" href="javascript:void(0);" target="_blank"><@t.page 'button.view'/></a>
                </#if>
            </#if>
            <#break>
        <#case 'image'>
            <#if 'view'=type>
                <img src="${getAbsoluteUrl(site.sitePath,value)!}" style="max-width:200px;max-height:200px;"/>
                <br/>
                ${(value)!}
            <#else>
                <input name="${inputName}" size="50" <#if 'customform'!=type>class="<#if extend.required>required</#if>" type="text" maxlength="300" size="50" <#else>type="file" accept="image/*" </#if>value="${(value)!}"/>
                <#if 'customform'!=type>
                    <a class="btnAttach" href="common/upload.html?field=${inputName?url}&fileTypes=image&width=${extend.width!}&height=${extend.height!}" lookupGroup="" width="1000" height="600"><@t.page 'image'/></a>
                    <a class="view icon-eye-open" ref="${inputName}" data-prefix="${site.sitePath}" href="javascript:void(0);" target="_blank"><@t.page 'button.view'/></a>
                    <#if !preview?has_content>
                        <#include "../include_page/preview.html"/>
                    </#if>
                    <@preview extend.id.code 'input[name="${inputName}"]' ''/>
                </#if>
            </#if>
            <#break>
        <#case 'video'>
            <#if 'view'=type>
                <video controls="controls" src="${getAbsoluteUrl(site.sitePath,value)!}" style="max-width:500px;max-height:500px;"></video>
                <br/>
                ${(value)!}
            <#else>
                <input name="${inputName}" <#if 'customform'!=type>class="<#if extend.required>required</#if>" type="text" maxlength="300" size="50" <#else>type="file" accept="video/*"</#if>value="${(value)!}"/>
                <#if 'customform'!=type>
                    <a class="btnAttach" href="common/upload.html?field=${inputName?url}&fileTypes=video" lookupGroup="" width="1000" height="600"><@t.page 'video'/></a>
                    <a class="view icon-eye-open" ref="${inputName}" data-prefix="${site.sitePath}" href="javascript:void(0);" target="_blank"><@t.page 'button.view'/></a>
                </#if>
            </#if>
            <#break>
        <#case 'password'>
            <#if 'view'=type>
                ${(value)!}
            <#else>
                <input name="${inputName}"<#if extend.maxlength?has_content> size="${extend.maxlength}" maxlength="${extend.maxlength}"<#else> size="30"</#if> <#if 'customform'!=type>class="<#if extend.required> required</#if>" </#if>type="password" value="${(value)!}"/>
            </#if>
            <#break>
        <#case 'textarea'>
            <#if 'view'=type>
                <pre>${(value)!}</pre>
            <#else>
                <textarea name="${inputName}"<#if extend.maxlength?has_content> maxlength="${extend.maxlength}"</#if> <#if 'customform'!=type>class="<#if extend.required>required</#if>" </#if>cols="80" rows="4">${(value)!}</textarea>
            </#if>
            <#break>
        <#case 'editor'>
            <#if 'view'=type>
                <#if safe>${(value?no_esc)!}<#else>${value!}</#if>
            <#else>
                <textarea name="${inputName}"<#if extend.maxlength?has_content> maxlength="${extend.maxlength}"</#if> <#if 'customform'!=type>class="editor<#if extend.required> required</#if>" </#if>cols="80" rows="20">${(value)!}</textarea>
            </#if>
            <#break>
        <#case 'ckeditor'>
            <#if 'view'=type>
                <#if safe>${(value?no_esc)!}<#else>${value!}</#if>
            <#else>
                <textarea name="${inputName}"<#if extend.maxlength?has_content> maxlength="${extend.maxlength}"</#if> <#if 'customform'!=type>class="editor<#if extend.required> required</#if>" editorType="ckeditor" </#if>cols="80" rows="20">${(value)!}</textarea>
            </#if>
            <#break>
        <#case 'kindeditor'>
            <#if 'view'=type>
                <#if safe>${(value?no_esc)!}<#else>${value!}</#if>
            <#else>
                <textarea name="${inputName}"<#if extend.maxlength?has_content> maxlength="${extend.maxlength}"</#if> <#if 'customform'!=type>class="editor<#if extend.required> required</#if>" editorType="kindeditor" </#if>cols="80" rows="20">${(value)!}</textarea>
            </#if>
            <#break>
        <#case 'template'>
            <#if 'view'=type>
                ${(value)!}
            <#else>
                <input name="${inputName}"<#if extend.maxlength?has_content> maxlength="${extend.maxlength}"</#if> type="text" maxlength="255" size="40" value="${(value)!}"<#if 'customform'!=type> class="<#if extend.required> required</#if>"</#if>/>
                <a class="btnLook" href="cmsTemplate/lookup.html?field=${inputName?url}" lookupGroup=""><@t.page 'template.select'/></a>
            </#if>
            <#break>
        <#case 'boolean'>
            <#if 'view'=type>
                <#if value?has_content>${('true'=value)?then(t.pageMessage('yes'),t.pageMessage('no'))}</#if>
            <#else>
                <select class="combox" name="${inputName}"<#if 'customform'!=type> class="<#if extend.required> required</#if>"</#if>>
                    <option value="true"${(value?has_content&&'true'=value)?then(' selected="true"','')?no_esc}><@t.page 'yes'/></option>
                    <option value="false"${(!value?has_content||'false'=value)?then(' selected="true"','')?no_esc}><@t.page 'no'/></option>
                </select>
            </#if>
            <#break>
        <#case 'user'>
            <@_sysUser id=value><#local u=object/></@_sysUser>
            <#if 'view'=type>
                ${(value)!}:${(u.nickName)!}
            <#else>
                <input name="${inputName}" value="${(value)!}" type="hidden"/>
                <input name="${name}[${index}].nickName" readonly="readonly" size="30" value="${(u.nickName)!}" type="text"<#if 'customform'!=type> class="<#if extend.required> required</#if>"</#if>/>
                <a class="btnLook" href="sysUser/lookup.html?field=value" width="1200" height="580" lookupGroup="${name}[${index}]"><@t.page 'user.select'/></a>
            </#if>
            <#break>
        <#case 'dept'>
            <@_sysDept id=value><#local d=object/></@_sysDept>
            <#if 'view'=type>
                ${(value)!}:${(d.name)!}
            <#else>
                <input name="${inputName}" value="${(value)!}" type="hidden"/>
                <input name="${name}[${index}].deptName" readonly="readonly" size="30" value="${(d.name)!}" type="text"<#if 'customform'!=type> class="<#if extend.required> required</#if>"</#if>/>
                <a class="btnLook" href="sysDept/lookup.html?field=value" width="920" lookupGroup="${name}[${index}]"><@t.page 'dept.select'/></a>
            </#if>
            <#break>
        <#case 'content'>
            <@_content id=value><#local tempContent=object/></@_content>
            <#if 'view'=type>
                ${(value)!}:${(tempContent.title)!}
            <#else>
                <input name="${inputName}" value="${(value)!}" type="hidden"/>
                <input name="${name}[${index}].title" readonly="readonly" size="30" value="${(tempContent.title)!}" type="text"<#if 'customform'!=type> class="<#if extend.required> required</#if>"</#if>/>
                <a class="btnLook" href="cmsContent/lookup.html?field=value" lookupGroup="${name}[${index}]" width="1000" height="500"><@t.page 'content.select'/></a>
            </#if>
            <#break>
        <#case 'category'>
            <@_category id=value><#local tempCategory=object/></@_category>
            <#if 'view'=type>
                ${(value)!}:${(tempCategory=object.name)!}
            <#else>
                <input name="${inputName}" value="${(value)!}" type="hidden"/>
                <input name="${name}[${index}].categoryName" readonly="readonly" size="30" value="${(tempCategory=object.name)!}" type="text"<#if 'customform'!=type> class="<#if extend.required> required</#if>"</#if>/>
                <a class="btnLook" href="cmsCategory/lookup.html?field=value" lookupGroup="${name}[${index}]" width="1000" height="500"><@t.page 'category.select'/></a>
            </#if>
            <#break>
        <#case 'categoryType'>
            <@_categoryType id=value><#local categoryType=object/></@_categoryType>
            <#if 'view'=type>
                ${(value)!}:${(categoryType.name)!}
            <#else>
                <input name="${inputName}" value="${(value)!}" type="hidden"/>
                <input name="${name}[${index}].categoryTypeName" readonly="readonly" size="30" value="${(categoryType.name)!}" type="text"<#if 'customform'!=type> class="<#if extend.required> required</#if>"</#if>/>
                <a class="btnLook" href="cmsCategoryType/lookup.html?field=value" lookupGroup="${name}[${index}]" width="1000" height="500"><@t.page 'select'/></a>
            </#if>
            <#break>
        <#case 'tagType'>
            <@_tagType id=value><#local tagType=object/></@_tagType>
            <#if 'view'=type>
                ${(value)!}:${(tagType.name)!}
            <#else>
                <input name="${inputName}" value="${(value)!}" type="hidden"/>
                <input name="${name}[${index}].tagTypeName" readonly="readonly" size="30" value="${(tagType.name)!}" type="text"<#if 'customform'!=type> class="<#if extend.required> required</#if>"</#if>/>
                <a class="btnLook" href="cmsTagType/lookup.html?field=value" lookupGroup="${name}[${index}]" width="1000" height="500"><@t.page 'select'/></a>
            </#if>
            <#break>
        <#case 'tag'>
            <@_tag id=value><#local tag=object/></@_tag>
            <#if 'view'=type>
                ${(value)!}:${(tag.name)!}
            <#else>
                <input name="${inputName}" value="${(value)!}" type="hidden"/>
                <input name="${name}[${index}].tagName" readonly="readonly" size="30" value="${(tag.name)!}" type="text"<#if 'customform'!=type> class="<#if extend.required> required</#if>"</#if>/>
                <a class="btnLook" href="cmsTag/lookup.html?field=value" lookupGroup="${name}[${index}]" width="1000" height="500"><@t.page 'select'/></a>
            </#if>
            <#break>
        <#case 'vote'>
            <@_vote id=value><#local vote=object/></@_vote>
            <#if 'view'=type>
                ${(value)!}:${(vote.title)!}
            <#else>
                <input name="${inputName}" value="${(value)!}" type="hidden"/>
                <input name="${name}[${index}].voteName" readonly="readonly" size="30" value="${(vote.title)!}" type="text"<#if 'customform'!=type> class="<#if extend.required> required</#if>"</#if>/>
                <a class="btnLook" href="cmsVote/lookup.html?field=value" lookupGroup="${name}[${index}]" width="1000" height="500"><@t.page 'select'/></a>
            </#if>
            <#break>
        <#case 'dictionary'>
            <@_dictionary id=extend.dictionaryId><#local dictionary=object/></@_dictionary>
            <#if site.parentId?has_content&&!dictionary?has_content><@_dictionary id=extend.dictionaryId siteId=site.parentId><#local dictionary=object/></@_dictionary></#if>
            <#if dictionary?has_content>
                <#if 'view'=type>
                    <@_dictionaryData dictionaryId=extend.dictionaryId values=value><#list map as k,data>${data.text}<#sep>,</#list></@_dictionaryData>
                <#else>
                    <#local dictionaryId='dictionary_'+.now?long/>
                    <div class="dictionary" data-id="${dictionary.id.id}" data-ref="<@_dictionaryExcludeList dictionaryId=dictionary.id.id><#list list as a>${a.id.excludeDictionaryId}<#sep>,</#list></@_dictionaryExcludeList>" data-url="common/dictionaryExclude.html" id="${dictionaryId}">
                       <@dictionaryElement extend.dictionaryId inputValuesName extend.required dictionary.childDepth extend.multiple type value/>
                    </div>
                    <@_sysAuthorized roleIds=admin.roles url='cmsDictionary/add'>
                        <a href="common/dictionary.html?id=${dictionary.id.id}&inputName=inputValuesName&required=${extend.required!}&multiple=${extend.multiple!}&value=${value!}" target="ajax" rel="${dictionaryId}"><i class="icon-refresh"></i> <@t.page 'button.refresh'/></a>
                        <#if dictionary.childDepth gt 0>
                            <a href="cmsDictionary/addChild.html?id=${dictionary.id.id}" target="dialog" mask="true" icon="<i class='icon-edit'></i>"><@t.page 'dictionary.edit'/></a>
                        <#else>
                            <a href="cmsDictionary/add.html?id=${dictionary.id.id}" target="navTab" rel="cmsDictionary/edit" icon="<i class='icon-edit'></i>"><@t.page 'dictionary.edit'/></a>
                        </#if>
                    </@_sysAuthorized>
                </#if>
            </#if>
            <#break>
        <#case 'date'>
            <#if 'view'=type>
                ${(value)!}
            <#else>
                <input name="${inputName}" <#if 'customform'!=type>class="date<#if extend.required> required</#if>" autocomplete="off" dateFmt="yyyy-MM-dd" </#if>type="text" size="10" value="${(value)!}"/>
            </#if>
            <#break>
        <#case 'datetime'>
            <#if 'view'=type>
                ${(value)!}
            <#else>
                <input name="${inputName}" <#if 'customform'!=type>class="date<#if extend.required> required</#if>" autocomplete="off" dateFmt="yyyy-MM-dd HH:mm:ss" </#if>type="text" size="20" value="${(value)!}"/>
            </#if>
            <#break>
        <#default>
            <#if 'view'=type>
                ${(value)!}
            <#else>
                <input name="${inputName}"<#if extend.maxlength?has_content> size="${extend.maxlength}" maxlength="${extend.maxlength}"<#else> size="50"</#if> <#if 'customform'!=type>class="<#if extend.required> required</#if>" </#if>type="text" value="${(value)!}"/>
            </#if>
    </#switch>
</#macro>
<#macro extendData name extendList extendValues type='form' fromIndex=0 htmlSafe=false>
    <#list extendList as e>
    <#local value=extendValues[e.id.code]!e.defaultValue!''/>
        <#if 'customform'=type>
    <p><label>${(e.name)}:</label><@input name e e?index+fromIndex value type/></p>
        <#else>
    <dl class="nowrap">
        <dt>${(e.name)}:</dt>
        <dd<#if 'editor'=e.inputType> style="width:90%;"</#if>>
            <@input name e e?index+fromIndex value type/>
            <span class="info">${(htmlSafe?then(e.description?no_esc,e.description))!}</span>
        </dd>
    </dl>
        </#if>
    </#list>
</#macro>